/**
 * Created by zhangxiaoyu on 2016-10-09.
 */
angular.module('hyt.hzdzService',[])
    .factory('HzdzListFactory',function($rootScope,ENV,$resource,Storage,$ionicLoading,$state){
        var hzDzListData={};
        var APIUrl= Storage.get('fwqdz');
        var resource=$resource(APIUrl);
        return{
            hzDzList:function(sid,user_id,yh_id,dw_id,zd_id){
                return resource.save({
                    SID:sid,
                    USER_ID:user_id,
                    ACTION_NAME:'sqlKeyBiz.list#fhr_wlgs_duizhang',
                    ACTION_INFO:{
                        "yh_id": yh_id,
                        'dw_id':dw_id,
                        'zd_id':zd_id
                    }
                },function(resp){
                    var resp=resp;
                    if(resp.ACTION_RETURN_CODE == "000000"){
                        hzDzListData= resp.ACTION_INFO.RESULT_LIST[0];
                        $rootScope.$broadcast('HzdzList.hzdzUpdated');
                    }else if (resp.ACTION_RETURN_CODE == "000005"){
                        $ionicLoading.show({
                            noBackdrop: true,
                            template: "您的账号已在其他设备登录",
                            duration: 1500
                        });
                        $state.go("login");
                    }
                })
            },
            //获取客户对账财务列表单页数据
            getResult : function(){
                return hzDzListData;
            }
        }
    })
